#include "StdAfx.h"
#include "MyLog.h"
#include "stdarg.h"

CMyLog::CMyLog(void)
{
}

CMyLog::~CMyLog(void)
{
}

void CMyLog::Msg(const char *fmt, ...)
{
	va_list args;
	char buf[1024] = {0};

	va_start(args, fmt);
	_vsnprintf_s(buf, sizeof(buf), _TRUNCATE, fmt, args);
	va_end(args);

//#ifdef WIN32
	OutputDebugStringA(buf);
//#endif
}

void CMyLog::PHex(const char *data, int len)
{
	return;
	if (!data||len<1)
		return;

	char buf[1024] = {0};

	int j = 0;
	for (int i=0; i<len; ++i,j+=2)
	{
		sprintf(&buf[j],"%02X", data[i]);
	}
	sprintf(buf, "\n");
	OutputDebugStringA(buf);
}


void CMyLog::Error(LPCTSTR msg)
{

#ifdef WIN32
	OutputDebugString(msg);
#endif
}

void CMyLog::Info(LPCTSTR msg)
{

#ifdef WIN32
	OutputDebugString(msg);
#endif
}


static char g_buf[1024] = {0};
CMLog::CMLog(const char *info)
{
	/*
	if (info)
	{
		bzero(g_buf, sizeof(g_buf));
		strncpy(g_buf, info, 1020);
		fprintf(stdout, "======== enter %s ========\n", g_buf);
	}
	*/
}

CMLog::~CMLog()
{
/*	if (strlen(g_buf)>0)
	{
		fprintf(stdout, "======= leave %s =========\n", g_buf);
		bzero(g_buf, sizeof(g_buf));
	}
	*/
}

void CMLog::Plog(const char *fmt, ...)
{
	va_list args;
	char buf[1024] = {0};

	va_start(args, fmt);
	vsnprintf(buf, sizeof(buf), fmt, args);
	va_end(args);

	OutputDebugStringA(buf);
	//fprintf(stdout, "[%s %d] %s\n", CMTools::GetCurDateTime(), CMTools::GetTick(), buf);
	//fprintf(stdout, "[%s]: %s\n", CMTools::GetCurTime(), buf);
}
